import { VNode, render } from 'vue'

/**
 * 节点hooks
 */
export const useNode = () => {
  return {
    /**
     * 追加节点
     * @param node 目标节点
     * @param root 根节点
     */
    appendNode: (node: VNode, root: HTMLElement = document.body) => {
      if (node) {
        // 将虚拟节点渲染成真实DOM
        render(node, root)
        root.appendChild(node.el as Node)
      }
    },
  }
}
